#include "MainWidget.h"
#include "ui_MainWidget.h"
#include <QDebug>

MainWidget::MainWidget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::MainWidget)
{
    ui->setupUi(this);

    //  **** 线程  ****
    ui->stopThread->setEnabled(false);
}

MainWidget::~MainWidget()
{
    delete ui;
}


void MainWidget::on_startThread_pressed()
{
    my_thread.start();
    ui->startThread->setEnabled(false);
    ui->stopThread->setEnabled(true);
}


void MainWidget::on_stopThread_pressed()
{
    if (my_thread.isRunning()) {
        my_thread.stop();
        ui->startThread->setEnabled(true);
        ui->stopThread->setEnabled(false);
    }
}

void MainWidget::on_isRunning_pressed()
{
    if (my_thread.isRunning()) {
        qDebug() << "======= thread is running =======";
    } else {
        qDebug() << "======= thread not running =======";
    }
}

void MainWidget::on_isFinished_pressed()
{
    if (my_thread.isFinished()) {
        qDebug() << "======= thread finished =======";
    } else {
        qDebug() << "======= thread not finished =======";
    }
}

